<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
  <link rel="stylesheet" href="/c/Public/css/wxjsdemo.css">
   <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
   <script src="/c/Public/js/zepto.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
        <script>
            wx.config({
            	debug:true,
            	appId: '<?php echo ($signPackage["appId"]); ?>',
                timestamp: <?php echo ($signPackage["timestamp"]); ?>,
                nonceStr: '<?php echo ($signPackage["nonceStr"]); ?>',
                signature: '<?php echo ($signPackage["signature"]); ?>',
               jsApiList: [
                           'checkJsApi',
                           'onMenuShareTimeline',
                           'onMenuShareAppMessage',
                           'onMenuShareQQ',
                           'onMenuShareWeibo',
                           'onMenuShareQZone',
                           'hideMenuItems',
                           'showMenuItems',
                           'hideAllNonBaseMenuItem',
                           'showAllNonBaseMenuItem',
                           'translateVoice',
                           'startRecord',
                           'stopRecord',
                           'onVoiceRecordEnd',
                           'playVoice',
                           'onVoicePlayEnd',
                           'pauseVoice',
                           'stopVoice',
                           'uploadVoice',
                           'downloadVoice',
                           'chooseImage',
                           'previewImage',
                           'uploadImage',
                           'downloadImage',
                           'getNetworkType',
                           'openLocation',
                           'getLocation',
                           'hideOptionMenu',
                           'showOptionMenu',
                           'closeWindow',
                           'scanQRCode',
                           'chooseWXPay',
                           'openProductSpecificView',
                           'addCard',
                           'chooseCard',
                           'openCard'
                  ]
              }); 
            //config验证成功
            wx.ready(function () {
                  // 1 判断当前版本是否支持指定 JS 接口，支持批量判断
                wx.checkJsApi({
                  jsApiList: [
                              'checkJsApi',
                              'onMenuShareTimeline',
                              'onMenuShareAppMessage',
                              'onMenuShareQQ',
                              'onMenuShareWeibo',
                              'onMenuShareQZone',
                              'hideMenuItems',
                              'showMenuItems',
                              'hideAllNonBaseMenuItem',
                              'showAllNonBaseMenuItem',
                              'translateVoice',
                              'startRecord',
                              'stopRecord',
                              'onVoiceRecordEnd',
                              'playVoice',
                              'onVoicePlayEnd',
                              'pauseVoice',
                              'stopVoice',
                              'uploadVoice',
                              'downloadVoice',
                              'chooseImage',
                              'previewImage',
                              'uploadImage',
                              'downloadImage',
                              'getNetworkType',
                              'openLocation',
                              'getLocation',
                              'hideOptionMenu',
                              'showOptionMenu',
                              'closeWindow',
                              'scanQRCode',
                              'chooseWXPay',
                              'openProductSpecificView',
                              'addCard',
                              'chooseCard',
                              'openCard'
                  ], 
                  success:function(res){
                	  alert('chenggong');
                  }
                });
            });
            //config验证失败
            wx.error(function(res){
            	aler('config 验证失败');
            	aler(res);
            });
         // 9 微信原生接口
            // 9.1.1 扫描二维码并返回结果
            document.querySelector('#scanQRCode0').onclick = function () {
              wx.scanQRCode();
            };
            // 9.1.2 扫描二维码并返回结果
            document.querySelector('#scanQRCode1').onclick = function () {
              wx.scanQRCode({
                needResult: 1,
                desc: 'scanQRCode desc',
                success: function (res) {
                  alert(JSON.stringify(res));
                }
              });
            };
            document.querySelector('#scanQRCode3').onclick = function () {
            	alert('点击按钮');
            	wx.getNetworkType({
            	    success: function (res) {
            	        var networkType = res.networkType; // 返回网络类型2g，3g，4g，wifi
            	        alert(networkType);
            	    }
            	});
              };
              document.getElementById('scanQRCode3').onclick = function () {
              	alert('点击按钮');
              	wx.getNetworkType({
              	    success: function (res) {
              	        var networkType = res.networkType; // 返回网络类型2g，3g，4g，wifi
              	        alert(networkType);
              	    }
              	});
                };
                function test(){
                	alert('点击按钮');
                  	wx.getNetworkType({
                  	    success: function (res) {
                  	        var networkType = res.networkType; // 返回网络类型2g，3g，4g，wifi
                  	        alert(networkType);
                  	    }
                  	});
                }
        </script>
        
</head>
<body>
<button class="btn btn_primary" id="scanQRCode0">scanQRCode(微信处理结果)</button>
<button class="btn btn_primary" id="scanQRCode1">scanQRCode(直接返回结果)</button>
<button class="btn btn_primary" id="scanQRCode3" onclick = "test()">网络状态</button>
</body>
</html>